➤ Limit Ranges
Limit Ranges in Kubernetes allow administrators to define default resource requests and limits for Pods, containers, and PersistentVolumeClaims (PVCs) within a namespace.
This ensures that individual Pods or containers do not exceed specified resource limits, preventing any single Pod from consuming excessive resources.
By using Limit Ranges, you can control resource usage for Pods, containers, and PVCs, ensuring efficient and fair resource distribution across your cluster.


$ kubectl create ns example-namespace


$ kubectl apply -f LimitRange.yaml


$ kubectl describe limitrange limit-range-example -n example-namespace
Name:                  limit-range-example
Namespace:             example-namespace
Type                   Resource  Min    Max   Default Request  Default Limit  Max Limit/Request Ratio
----                   --------  ---    ---   ---------------  -------------  -----------------------
Pod                    cpu       200m   2     -                -              4
Pod                    memory    256Mi  4Gi   -                -              8
Container              cpu       100m   1     250m             500m           2
Container              memory    128Mi  1Gi   256Mi            512Mi          4
PersistentVolumeClaim  storage   1Gi    10Gi  2Gi              5Gi            2


$ kubectl describe ns example-namespace
Name:         example-namespace
Labels:       kubernetes.io/metadata.name=example-namespace
Annotations:  <none>
Status:       Active
No resource quota.
Resource Limits
 Type                   Resource  Min    Max   Default Request  Default Limit  Max Limit/Request Ratio
 ----                   --------  ---    ---   ---------------  -------------  -----------------------
 Pod                    cpu       200m   2     -                -              4
 Pod                    memory    256Mi  4Gi   -                -              8
 Container              cpu       100m   1     250m             500m           2
 Container              memory    128Mi  1Gi   256Mi            512Mi          4
 PersistentVolumeClaim  storage   1Gi    10Gi  2Gi              5Gi            2


$ kubectl apply -f Deployment.yml


$ kubectl get all -n example-namespace
NAME                              READY   STATUS    RESTARTS   AGE
pod/limit-test-644b6d87f4-lhnfn   1/1     Running   0          28m

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/limit-test   1/1     1            1           28m

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/limit-test-644b6d87f4   1         1         1       28m


$ kubectl describe po limit-test-644b6d87f4-lhnfn -n example-namespace
......
......
Containers:
  nginx-deploy:
    Container ID:   docker://47327371302bb2b6022f6005d34986c7e6f95a4e326549c2e93a029ab1281cf7
    Image:          nginx:latest
    Image ID:       docker-pullable://nginx@sha256:42e917aaa1b5bb40dd0f6f7f4f857490ac7747d7ef73b391c774a41a8b994f15
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Thu, 26 Dec 2024 15:08:38 +0000
    Ready:          True
    Restart Count:  0
    Limits:
      cpu:     500m
      memory:  512Mi
    Requests:
      cpu:        250m
      memory:     256Mi
......
......



[LINK]
https://medium.com/@muppedaanvesh/a-hand-on-guide-to-kubernetes-resource-quotas-limit-ranges-%EF%B8%8F-8b9f8cc770c5
